<script setup lang="ts">
	import { ref, watch } from "vue";
	import {
		useRouter
	} from 'uni-mini-router'
	import {
		getCurrentInstance
	} from 'vue'
	import { onLoad, onUnload, onShow } from '@dcloudio/uni-app';
	import {
		userStore
	} from '@/pinia';
	let router = useRouter()
	const userStoreInfo = userStore();
	const {
		proxy,
	} = getCurrentInstance()
	let goodsArr = ref([])
	let radioValue = ref('拉卡拉')
	let payConfirmShow = ref(false)
	let zulinDay = ref()
	let radiolist = ref([
		// 	{
		// 	name: '微信',
		// 	logo: '../../../static/icon/wxPay.png'
		// }, 
		{
			name: '拉卡拉',
			logo: '../../../static/icon/aliPay.png'
		}])
	const routerLink = (e) => {
		//选择地址或者结算
		uni.$on('choseAddress', (data) => {
			addressObj.value = data.address
			uni.$off('choseAddress')
		})
		router.push({
			name: e,
			params: {}
		})
	}
	onUnload(() => {
		//页面卸载移除全局事件
		uni.$off('choseAddress')
	})
	const radioClick = (name) => {
		radioValue.value = name
		console.log(radioValue.value);
	}
	let orderData = ref(null)
	let addressObj = ref(null)
	let payUrl = ref('')
	const getList = () => {
		//获取默认地址
		proxy.$req('GET', proxy.$api.shouhuodizhi, {
			memberId: userStoreInfo.userInfo.id,
			pageNo: 1,
			pageSize: 20,
			isDefault: 1
		}).then((res) => {
			console.log(res);
			addressObj.value = res.result.records[0]
		})
	}
	getList()
	let juanList = ref([])
	// const getJuan = () => {
	// 	//根据店铺id获取优惠卷
	// 	proxy.$req('GET', proxy.$api.getStoreJuan, {
	// 		storeId: orderData.value.goodObj.meiyeSupplier.id
	// 	}).then((res) => {
	// 		juanList.value = res.result.records
	// 	})
	// }
	const getJuanMy = (ids) => {
		//获取我名下的卷
		proxy.$req('POST', proxy.$api.xiadanJuan, {
			storeIds: ids,
			status: 0,
			pageNo: 1,
			pageSize: 50
		}).then((res) => {
			juanList.value = res.result.records
		})
	}
	let checkedJuan = ref({})
	let heji = ref(0)
	let yunfei = ref(0)
	let payMoney = ref(0)
	let deposit = ref(0)
	watch(checkedJuan, (newVal, oldVal) => {
		//监听优惠卷，判断总价
		console.log(newVal, oldVal);
		if (heji.value >= newVal.useMinPrice) {
			payMoney.value = heji.value - newVal.couponPrice + yunfei.value
		} else {
			payMoney.value = heji.value + yunfei.value
		}
		//总价加上押金
		if (deposit.value) {
			payMoney.value += deposit.value
		}
	})
	let timeId = ref()
	watch(payConfirmShow, (newVal, oldVal) => {
		if (!newVal && oldVal) {
			clearInterval(timeId.value)
		} else {

		}

	})
	onLoad((options) => {
		//页面初始化带过来商品数据
		orderData.value = JSON.parse(options.data)
		console.log(orderData.value, "打印订单数据");
		if (orderData.value.type == 1) {
			let price
			let vipPrice
			let lastPrice
			//判断是不是平台vip，是否享受会员价格
			if (userStoreInfo.userInfo.isVip) {
				if (orderData.value.goodObj.specType == 1) {  //判断是否是多规格商品，如果是价格选择sku里的，不是就直接选择goodObj里的价格，
					price = orderData.value.sku.sku.price
					vipPrice = orderData.value.sku.sku.linePrice
				} else {
					price = orderData.value.goodObj.price
					vipPrice = orderData.value.goodObj.vipPrice
				}
				lastPrice = vipPrice
				// lastPrice = price
			} else {
				vipPrice = null
				if (orderData.value.goodObj.specType == 1) {
					price = orderData.value.sku.sku.price
				} else {
					price = orderData.value.goodObj.price
				}
				console.log(price, "打印price")
				lastPrice = price
			}
			//type == 1,结算单个商品,结算单个商品可以直接获取单个商品的优惠卷

			goodsArr.value = [{
				title: orderData.value.goodObj.meiyeSupplier.storeName,
				glist: [{
					image: orderData.value.goodObj.image,
					name: orderData.value.goodObj.name,
					spec_key_name: orderData.value.sku.skuText.join('  '),
					// ? orderData.value.sku.skuText[0] : '' + orderData.value.sku.skuText[1] ? orderData.value.sku.skuText[1] : '',
					goodsZuqi: '',
					cartNum: orderData.value.sku.num,
					specType: orderData.value.goodObj.specType,
					// price: orderData.value.goodObj.price
					price,
					vipPrice
				}]
			}]
			//有带过来优惠卷的话赋值
			checkedJuan.value = orderData.value.juanObj
			//计算合计
			// heji.value = orderData.value.goodObj.price * orderData.value.sku.num
			heji.value = lastPrice * orderData.value.sku.num
			console.log(lastPrice, "打印价格")
			console.log(orderData.value.sku.num, "打印价格")
			//计算运费
			yunfei.value = orderData.value.goodObj.postage * orderData.value.sku.num

			//判断是不是租赁商品下单 
			if (orderData.value.goodType) {
				//押金赋值
				deposit.value = orderData.value.goodObj.ensureMoney * orderData.value.sku.num
				console.log(deposit.value, "打印押金总数")
				let a = orderData.value.startTime.split(' ')[0]
				let b = orderData.value.endTime.split(' ')[0]
				console.log(a, b)
				//总价乘以租赁天数
				zulinDay.value = getDiffDay(a, b) + 1
				heji.value = heji.value * zulinDay.value
			}
			//详情进入下单，单店，获取下这个店的优惠卷
			getJuanMy([orderData.value.goodObj.meiyeSupplier.id])
		} else {
			//购物车进结算页
			console.log(orderData.value.goodsList, "打印购物车商品数据");
			let Arr = orderData.value.goodsList
			console.log(Arr.filter(obj => obj.glist.length > 0), "打印过滤数据")
			orderData.value.goodsList = Arr.filter(obj => obj.glist.length > 0)
			//构建显示/商品的数组
			goodsArr.value = orderData.value.goodsList
			//计算商品合计
			orderData.value.goodsList.forEach((item) => {
				item.glist.forEach((it) => {
					//运费
					yunfei.value += it.cartNum * it.postage
					//是否是租赁商品
					if (it.isType == 1) {
						//获取商品的租赁日期，然后进行计算天数
						let a = it.startTime.split(' ')[0]
						let b = it.endTime.split(' ')[0]
						//计算押金 和 商品合计
						deposit.value += it.ensureMoney * it.cartNum
						//是否是多规格商品
						if (it.specType == 1) {
							//如果是会员
							if (userStoreInfo.userInfo.isVip) {
								heji.value += (it.sku.linePrice * it.cartNum * (getDiffDay(a, b) + 1))
							} else {
								heji.value += (it.sku.price * it.cartNum * (getDiffDay(a, b) + 1))
							}

						} else {
							//如果是会员
							if (userStoreInfo.userInfo.isVip) {
								heji.value += (it.vipPrice * it.cartNum * (getDiffDay(a, b) + 1))
							} else {
								heji.value += (it.price * it.cartNum * (getDiffDay(a, b) + 1))
							}

						}
					} else {
						//只计算商品合计
						if (it.specType == 1) {  //是否是多规格
							//如果是会员
							if (userStoreInfo.userInfo.isVip) {
								heji.value += (it.sku.linePrice * it.cartNum)
							} else {
								heji.value += (it.sku.price * it.cartNum)
							}
						} else {
							//如果是会员
							if (userStoreInfo.userInfo.isVip) {
								heji.value += (it.vipPrice * it.cartNum)
							} else {
								heji.value += (it.price * it.cartNum)
							}
						}
					}
				})
			})
			console.log("打印押金总数", deposit.value)
			//计算运费
			// yunfei.value = orderData.value.goodsList[0].glist[0].postage 
			//触发监听器，计算总合计
			checkedJuan.value = {}
			//根据多个店铺的id获取可用优惠卷
			let ids = goodsArr.value.map((item) => { return item.shopId })
			//获取多个店铺可用的卷
			getJuanMy(ids)
		}
	})
	let tradeNo = ref('')
	let payId = ref('')
	const addOrder = () => {
		if (addressObj.value == null) {
			uni.$u.toast('请先添加地址')
			return
		}
		if (payUrl.value != '' && tradeNo.value != '' && payId.value != '') {
			payLKL()
			return
		}
		if (orderData.value.type == 1) {
			//下单单个商品
			let data = []
			if (orderData.value.goodObj.specType == 0) {
				data = [{
					cartId: '',
					productId: orderData.value.goodObj.id,
					cartNum: orderData.value.sku.num,
					startTime: orderData.value.startTime,
					endTime: orderData.value.endTime,
				}]
			} else {
				data = [{
					skuId: orderData.value.sku.sku.id,
					cartId: '',
					productId: orderData.value.goodObj.id,
					cartNum: orderData.value.sku.num,
					startTime: orderData.value.startTime,
					endTime: orderData.value.endTime,
				}]
			}

			let a = {
				orderType: orderData.value.goodType,
				realName: addressObj.value.realName,
				userPhone: addressObj.value.phone,
				userAddress: addressObj.value.detail,
				couponId: checkedJuan.value.couponId ? checkedJuan.value.couponId : null,
				orderInfoList: data
			}
			console.log(a, "打印下单数据")
			//订单类型不确认orderType 0 商品 1租赁，暂时写0
			proxy.$req('POST', proxy.$api.addOrder, {
				orderType: orderData.value.goodType,
				realName: addressObj.value.realName,
				userPhone: addressObj.value.phone,
				userAddress: addressObj.value.detail,
				couponId: checkedJuan.value.couponId ? checkedJuan.value.couponId : null,
				orderInfoList: data
			}).then((res) => {
				console.log(res);
				if (!res.success) {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
					return
				}
				payUrl.value = res.result.resp_data.counter_url
				tradeNo.value = res.result.resp_data.out_order_no
				payId.value = res.result.resp_data.pay_order_no
				payConfirmShow.value = true

				// timeId.value = setInterval(() => {
				// isPaySuccess(timeId.value)
				// }, 2000)
			})
		} else {
			//购物车下单
			console.log(orderData.value, "打印orderData");
			console.log(orderData.value.goodsList, "打印goodsList");
			let data = []
			orderData.value.goodsList.map((item, index) => {
				item.glist.forEach((it, key) => {
					data = data.concat([{
						skuId: it.skuId,
						cartId: it.cartId,
						productId: it.id,
						cartNum: it.cartNum,
						startTime: it.startTime,
						endTime: it.endTime
					}])
				})
			})
			let d = {
				realName: addressObj.value.realName,
				userPhone: addressObj.value.phone,
				userAddress: addressObj.value.detail,
				couponId: checkedJuan.value.id ? checkedJuan.value.id : null,
				orderInfoList: data
			}
			console.log(d, "打印上传数据的")
			//订单类型不确认orderType 0 商品 1租赁，暂时写0
			proxy.$req('POST', proxy.$api.addCarOrder, {
				// orderType: 0,
				realName: addressObj.value.realName,
				userPhone: addressObj.value.phone,
				userAddress: addressObj.value.detail,
				couponId: checkedJuan.value.id ? checkedJuan.value.id : null,
				orderInfoList: data
			}).then((res) => {
				console.log(res);
				if (!res.success) {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
					return
				}
				payUrl.value = res.result.resp_data.counter_url
				tradeNo.value = res.result.resp_data.out_order_no
				payId.value = res.result.resp_data.pay_order_no
				payConfirmShow.value = true
			})
		}
	}
	onShow(() => {
		// uni.showToast({
		// 	title: '正在查询支付状态',
		// 	duration: 2000
		// });
		console.log("掉接口啊")
		if (tradeNo.value != '' && payId.value != '') {
			// timeId.value = setInterval(() => {
			// 	console.log("定时器里面")
			// isPaySuccess(timeId.value)
			// }, 1000)
			isPaySuccess()
		}
	})
	// const isPaySuccess = (timeId) => {
	// 	proxy.$req('POST', proxy.$api.ShoppingStoreOrder, {
	// 		tradeNo:tradeNo.value,
	// 		payId:payId.value
	// 	}).then((res) => {
	// 		if(res.code != 200 || res.result == null){
	// 			console.log("出错了")
	// 			uni.$u.toast(res.message)
	// 			clearInterval(timeId)
	// 			return
	// 		}
	// 		console.log(res);
	// 		let a = JSON.parse(JSON.stringify(res)).result
	// 		let data = JSON.parse(a).resp_data
	// 		console.log(data,'打印data')
	// 		if (data.order_status == 0) {
	// 			uni.$u.toast('待支付')
	// 			clearInterval(timeId)
	// 		} else if (data.order_status == 1) {
	// 			uni.$u.toast('支付中')
	// 			clearInterval(timeId)
	// 		} else if (data.order_status == 2) {
	// 			uni.$u.toast('支付成功')
	// 			clearInterval(timeId)
	// 		} else if(data.order_status == 3){
	// 			uni.$u.toast('支付失败')
	// 			clearInterval(timeId)
	// 		} else if(data.order_status == 4){
	// 			uni.$u.toast('订单已过期')
	// 			clearInterval(timeId)
	// 		}else if(data.order_status == 5){
	// 			uni.$u.toast('订单已取消')
	// 			clearInterval(timeId)
	// 		}else if(data.order_status == 6){
	// 			uni.$u.toast('部分退款或者全部退款')
	// 			clearInterval(timeId)
	// 		}
	// 	})
	// }
	const isPaySuccess = () => {
		proxy.$req('POST', proxy.$api.ShoppingStoreOrder, {
			tradeNo: tradeNo.value,
			payId: payId.value
		}).then((res) => {
			if (res.code != 200 || res.result == null) {
				console.log("出错了")
				uni.$u.toast(res.message)
				return
			}
			let a = JSON.parse(JSON.stringify(res)).result
			let data = JSON.parse(a).resp_data
			if (data.order_status == 0) {
				uni.$u.toast('待支付')
			} else if (data.order_status == 1) {
				uni.$u.toast('支付中')
			} else if (data.order_status == 2) {
				uni.$u.toast('支付成功')
				router.push({
					name: 'payResult',
					params: {
						status: '支付成功',
						backNum: 3
					}
				})
				// setTimeout(() => {
				// 	uni.navigateBack({
				// 		delta: 2
				// 	});
				// },1000)
			} else if (data.order_status == 3) {
				uni.$u.toast('支付失败')
			} else if (data.order_status == 4) {
				uni.$u.toast('订单已过期')
			} else if (data.order_status == 5) {
				uni.$u.toast('订单已取消')
			} else if (data.order_status == 6) {
				uni.$u.toast('部分退款或者全部退款')
			}
		})
	}
	const payNow = () => {
		//确认付款
		proxy.$req('GET', proxy.$api.shouhuodizhi, {
			memberId: userStoreInfo.userInfo.id,
			pageNo: 1,
			pageSize: 20,
			isDefault: 1
		}).then((res) => {
			console.log(res);
			addressObj.value = res.result.records[0]
		})
	}
	let youhuiShow = ref(false)
	let youhuiClose = () => {
		//关闭优惠弹框
		youhuiShow.value = false
	}
	const useJuan = (item) => {
		if (item.useMinPrice > (heji.value + yunfei.value)) {
			uni.showToast({
				title: '商品不满足满减',
				icon: 'none'
			})
			return
		}
		checkedJuan.value = item
		youhuiShow.value = false
	}
	const opJuan = () => {
		if (juanList.value.length > 0) {
			youhuiShow.value = true
		} else {
			uni.showToast({
				title: '暂无可用优惠券',
				icon: 'none'
			})
		}
	}
	const payLKL = () => {
		// #ifdef APP-PLUS
		// plus.runtime.openURL(payUrl.value)
		console.log('app')
		router.push({
			name: 'webviewPay',
			params: {
				url: payUrl.value
			}
		})
		// #endif
		// #ifdef H5
		window.open(payUrl.value)
		console.log('h5')
		// #endif 
		// timeId.value = setInterval(() => {
		// isPaySuccess(timeId.value)
		// }, 2000)
	}
	//计算租赁天数
	const getDiffDay = (date_1, date_2) => {
		// 计算两个日期之间的差值
		let totalDays, diffDate
		let myDate_1 = Date.parse(date_1)
		let myDate_2 = Date.parse(date_2)
		// 将两个日期都转换为毫秒格式，然后做差
		diffDate = Math.abs(myDate_1 - myDate_2) // 取相差毫秒数的绝对值

		totalDays = Math.floor(diffDate / (1000 * 3600 * 24)) // 向下取整
		// console.log(totalDays)    

		return totalDays    // 相差的天数
	}
</script>
<template>
	<template v-if="orderData!=null">
		<view class="all">
			<view class="addressBox r-flex-between-center" @click="routerLink('choseMineAddress')">
				<u-icon name="map-fill" size="20" color="#CB645E"></u-icon>
				<view class="addInfo" v-if="addressObj!=null">
					<text class="u-line-2"
						style="font-size: 32rpx;font-weight: 600;color: rgba(0,0,0,0.85);margin-bottom: 16rpx;">{{ addressObj.province}}
						{{ addressObj.city }}{{ addressObj.district }}{{ addressObj.detail }}</text>
					<view class="humanInfo r-flex-start-center">
						<text style="margin-right: 30rpx;color: rgba(0,0,0,0.65);">{{ addressObj.realName }}</text>
						<text style="color: rgba(0,0,0,0.45)">{{ addressObj.phone }}</text>
					</view>
				</view>
				<view class="" v-else>
					请选择地址
				</view>
				<u-icon name="arrow-right"></u-icon>
			</view>
			<view class="boxAll" v-for="item in goodsArr">
				<view class="title">
					<view class="titLeft">
						<text>{{ item.title }}</text>
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
				<view class="con" v-for="(it,key) in item.glist">
					<image class="conL" :src="it.image" mode=""></image>
					<view class="conR">
						<view class="rl c-flex-start-start">
							<text class="u-line-1" style="font-size: 28rpx;font-weight: 400;color: #33333	
								3;">{{ it.name }}</text>
							<text v-if="it.specType"
								style="font-size: 24rpx;font-weight: 400;color: rgba(0,0,0,0.45);padding-left: 30rpx;margin-top: 14rpx;">规格
								{{ it.spec_key_name }}</text>
							<text
								style="font-size: 24rpx;font-weight: 400;color: rgba(0,0,0,0.45);margin-top: 24rpx;">{{ it.goodsZuqi }}</text>
							<view v-if="orderData.type == 1 && orderData.goodType == 1"
								style="color:#999999;font-size: 20rpx;margin-bottom: 10rpx;">
								<view>开始日期: {{orderData.startTime}}</view>
								<view>结束日期: {{orderData.endTime}}</view>
							</view>
							<view v-if="it.startTime && it.endTime"
								style="color:#999999;font-size: 20rpx;margin-bottom: 10rpx;">
								<view>开始日期: {{it.startTime}}</view>
								<view>结束日期: {{it.endTime}}</view>
							</view>
						</view>
						<view class="rr">
							<!-- 	<view class="">
								<text style="font-size: 32rpx;font-weight: bold;color: #F22F19;"><text
										style="font-size: 20rpx;" class="intFont">￥</text>{{ it.price }}</text>
										<text v-if="it.linePrice">{{it.linePrice}}</text><br>
										<del style="padding-left: 70rpx;box-sizing: border-box;">{{it.linePrice}}</del>
							</view> -->
							<!-- 	<view class="" v-if="userStoreInfo.userInfo.isVip && orderData.type != 1">
								<text style="font-size: 32rpx;font-weight: bold;color: #F22F19;"><text
										style="font-size: 20rpx;" class="intFont">￥</text>{{it.linePrice}}</text><br>
								<del style="padding-left: 20rpx;box-sizing: border-box;">{{it.sku.price}}</del>
							</view>
							
							<view class="" v-else>
								<view class="" v-if="it.specType == 1 && orderData.type != 1">
										<text style="font-size: 32rpx;font-weight: bold;color: #F22F19;">
											<text style="font-size: 20rpx;" class="intFont">￥</text>{{ it.sku.price }}</text>
								</view>
								<view class="" v-else>
									<text style="font-size: 32rpx;font-weight: bold;color: #F22F19;">
										<text style="font-size: 20rpx;" class="intFont">￥</text>{{ it.price }}</text>
								</view>
							</view> -->


							<view class="" v-if="userStoreInfo.userInfo.isVip"><!-- //是否是平台会员 -->
								<view class="" v-if="it.specType == 0"> <!-- //是否是单规格商品 -->
									<view class="">
										<text style="font-size: 32rpx;font-weight: bold;color: #F22F19;"><text
												style="font-size: 20rpx;"
												class="intFont">￥</text>{{it.vipPrice}}</text><br>
										<del style="padding-left: 20rpx;box-sizing: border-box;">{{it.price}}</del>
									</view>

								</view>
								<view class="" v-else>
									<view class="" v-if="orderData.type == 1"> <!-- //商品单独下单 -->
										<text style="font-size: 32rpx;font-weight: bold;color: #F22F19;"><text
												style="font-size: 20rpx;"
												class="intFont">￥</text>{{it.vipPrice}}</text><br>
										<del style="padding-left: 20rpx;box-sizing: border-box;">{{it.price}}</del>
									</view>
									<view class="" v-else>
										<text style="font-size: 32rpx;font-weight: bold;color: #F22F19;"><text
												style="font-size: 20rpx;"
												class="intFont">￥</text>{{it.sku.linePrice}}</text><br>
										<del style="padding-left: 20rpx;box-sizing: border-box;">{{it.sku.price}}</del>
									</view>
								</view>
							</view>
							<view class="" v-else> <!-- //非平台会员 -->
								<view class="" v-if="it.specType == 0"> <!-- //单规格商品 -->
									<view class="">
										<text style="font-size: 32rpx;font-weight: bold;color: #F22F19;"><text
												style="font-size: 20rpx;"
												class="intFont">￥</text>{{it.price}}</text><br>
									</view>

								</view>
								<view class="" v-else> <!-- // 多规格商品 -->
									<view class="" v-if="orderData.type == 1"> <!-- //商品单独下单 -->
										<text style="font-size: 32rpx;font-weight: bold;color: #F22F19;"><text
												style="font-size: 20rpx;"
												class="intFont">￥</text>{{it.price}}</text><br>
									</view>
									<view class="" v-else> <!-- //购物车下单 -->
										<text style="font-size: 32rpx;font-weight: bold;color: #F22F19;"><text
												style="font-size: 20rpx;"
												class="intFont">￥</text>{{it.sku.price}}</text><br>
									</view>
								</view>
							</view>



							<text style="margin-top: 16rpx;font-size: 24rpx;color: rgba(0,0,0,0.45);">×
								{{ it.cartNum }}</text>
						</view>
					</view>
				</view>
			</view>
			<view class="youhui r-flex-between-center">
				<text style="color: #333333;">优惠券</text>
				<view class="r-flex-between-center" @click="opJuan">
					<text
						style="color: color: rgba(0,0,0,0.25);">{{ checkedJuan.couponTitle?checkedJuan.couponTitle:'选择' }}</text>
					<u-icon name="arrow-right" color="rgba(0,0,0,0.25);"></u-icon>
				</view>
			</view>
			<view class="infoBox">
				<view class="infoItem">
					<text>商品合计</text>
					<!-- {{ orderData.goodObj.price }} -->
					<text class="intFont">￥{{ heji.toFixed(2) }}</text>
				</view>
				<view class="infoItem" v-if="deposit">
					<text>押金</text>
					<text class="intFont">￥{{ deposit }}</text>
				</view>
				<view class="infoItem">
					<text>运费</text>
					<!-- {{ orderData.goodObj.postage }} -->
					<text class="intFont">￥{{ yunfei }}</text>
				</view>
				<!-- <view class="infoItem" v-if="orderData.goodObj.ensureMoney!=null">
					<text>押金</text>
					<text class="intFont">￥{{ orderData.goodObj.ensureMoney }}</text>
				</view> -->
				<view class="infoItem">
					<text>订单备注</text>
					<!-- <text>￥444</text> -->
					<input type="text" placeholder="填写备注" style="text-align: right;"
						placeholder-style="font-size:28rpx">
				</view>
			</view>
			<u-radio-group v-model="radioValue" placement="column">
				<view class="payWayBox c-flex-around-center">
					<view class="pItem r-flex-between-center" v-for="(item, index) in radiolist" :key="index"
						@click="radioClick(item.name)">
						<view class="pi1 r-flex-between-center">
							<image :src="item.logo" mode=""></image>
							<text>{{ item.name }}</text>
						</view>
						<view class="pi2">
							<u-radio active-color="#CB645E" :name="item.name">
							</u-radio>
						</view>
					</view>
				</view>
			</u-radio-group>
		</view>
		<view class="fixBox r-flex-end-center">
			<text style="font-size: 32rpx;font-weight: 400;color: #333333;">合计：</text>
			<text style="font-size: 28rpx;font-weight: bold;color: #F22F19;">￥</text>
			<text style="font-size: 44rpx;font-weight: bold;color: #F22F19;"
				class="intFont">{{ payMoney.toFixed(2) }}</text>
			<view class="jiesuan" @click="addOrder">
				结算
			</view>
		</view>
	</template>
	<u-popup :show="payConfirmShow" :closeable="true" @close="payConfirmShow=false" round="12">
		<view class="popClass">
			<view class="title r-flex-between-center">
				<text> </text>
				<text>确认付款</text>
				<!-- <u-icon name="close" style="opacity: 0;"></u-icon> -->
				<text></text>
			</view>
			<view class="money r-flex-center-end intFont">
				<text style="font-size: 48rpx;font-weight: bold;line-height: 1.5;">￥</text>
				<text>{{ payMoney.toFixed(2) }}</text>
			</view>
			<view class="msgBox r-flex-between-center" style="margin-top: 48rpx;">
				<text>订单编号</text>
				<text>{{payId}}</text>
			</view>
			<view class="msgBox r-flex-between-center">
				<text>付款方式</text>
				<text>拉卡拉支付</text>
			</view>
			<!-- <view class="nowPay" @click="payNow">
				立即付款
			</view> -->
			<view class="nowPay" @click="payLKL">
				立即付款
			</view>
		</view>
	</u-popup>
	<u-popup :show="youhuiShow" :round="12" @close="youhuiClose">
		<view style="height: 1300rpx;border-radius: 24rpx 24rpx 0rpx 0rpx;padding: 0 32rpx;">
			<view class="r-flex-between-center" style="height: 110rpx;">
				<text> </text>
				<text style="font-size: 36rpx;font-weight: 500;">优惠券</text>
				<u-icon name="close" @click="youhuiShow=false"></u-icon>
			</view>
			<view class="youhuijuan r-flex-center-center" v-for="(item,index) in juanList" :key="index">
				<view class="left c-flex-center-center">
					<view>
						<text style="font-size: 42rpx;font-weight: bold;color: #FFFFFF;margin-right: 6rpx;">￥</text>
						<text style="font-size: 80rpx;font-weight: bold;color: #FFFFFF;">{{ item.couponPrice }}</text>
					</view>
					<text style="font-size: 24rpx;font-weight: 400;color: #FFFFFF;">店铺优惠券</text>
				</view>
				<view class="right">
					<view class="rt">
						<text>限该店内使用</text>
						<text>{{ item.couponTitle }}</text>
					</view>
					<view class="rb r-flex-between-center">
						<view class="rb1">
							有效期至<br />
							{{ item.endTime }}
						</view>
						<view class="rb2" @click="useJuan(item)">
							使用
						</view>
					</view>
				</view>
			</view>
		</view>
	</u-popup>
</template>
<style lang="scss">
	page {
		background-color: #F6F6F6;
	}

	view {
		box-sizing: border-box;
	}

	.popClass {
		height: 718rpx;

		.title {
			margin: 32rpx 0;
			padding: 0 32rpx;
			font-size: 36rpx;
			font-weight: 500;
		}

		.money {
			font-size: 88rpx;
			font-weight: bold;
			color: #000000;
		}


		.msgBox {
			width: 100%;
			padding: 26rpx 48rpx;

			text:nth-child(1) {
				font-size: 28rpx;
				font-weight: 400;
				color: rgba(0, 0, 0, 0.45);
			}

			text:nth-child(2) {
				font-size: 28rpx;
				font-weight: 400;
				color: rgba(0, 0, 0, 0.85);
			}
		}

		.nowPay {
			margin: 0 auto;
			width: 686rpx;
			height: 88rpx;
			line-height: 88rpx;
			background: #CB645E;
			border-radius: 16rpx;
			color: #fff;
			text-align: center;
			font-size: 32rpx;
			font-weight: 500;
			margin-top: 136rpx;
		}
	}

	.all {
		width: 100%;
		padding: 0 32rpx 120rpx;

		.addressBox {
			width: 100%;
			height: 200rpx;
			padding: 32rpx 24rpx;
			margin: 16rpx 0;
			background: #FFFFFF;
			box-shadow: 8rpx 8rpx 32rpx 0rpx rgba(0, 0, 0, 0.04);
			border-radius: 24rpx;
			border: 2rpx solid #FFFFFF;

			.addInfo {
				width: 526rpx;
			}

			.humanInfo {
				font-size: 28rpx;
			}

		}
	}

	.boxAll {
		width: 100%;
		padding: 32rpx;
		margin: 16rpx 0;
		background: #FFFFFF;
		box-shadow: 8rpx 8rpx 32rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 24rpx;
		border: 2rpx solid #FFFFFF;

		.title {
			width: 100%;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.titLeft {
				display: flex;
				justify-content: center;
				align-items: center;
				font-size: 32rpx;
				font-weight: 500;
				color: rgba(0, 0, 0, 0.85);
				margin-bottom: 15rpx;

				image {
					width: 50rpx;
					height: 50rpx;
				}
			}
		}

		.con {
			width: 100%;
			padding: 0rpx 0;
			margin: 16rpx 0;
			display: flex;
			justify-content: space-between;
			align-items: flex-start;

			.conL {
				width: 176rpx;
				height: 176rpx;
			}

			.conR {
				width: 424rpx;
				display: flex;
				justify-content: space-between;
				align-items: flex-start;

				.rl {
					width: 338rpx;
					font-size: 28rpx;
				}

				.rr {
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					align-items: flex-end;
					font-size: 28rpx;
				}
			}
		}
	}

	.infoBox {
		width: 100%;
		padding: 0 32rpx;
		background-color: #FFFFFF;
		margin: 16rpx 0;
		box-shadow: 8rpx 8rpx 32rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 24rpx;
		border: 2rpx solid #FFFFFF;

		.infoItem {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 96rpx;
			font-size: 28rpx;
			font-weight: 400;
			color: #333333;
		}
	}

	.youhui {
		width: 100%;
		height: 96rpx;
		padding: 0 32rpx;
		background: #FFFFFF;
		box-shadow: 8rpx 8rpx 32rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 24rpx;
		border: 2rpx solid #FFFFFF;
		font-size: 28rpx;
		margin: 16rpx 0;
	}

	.payWayBox {
		width: 100%;
		height: 136rpx;
		padding: 0 32rpx;
		background: #FFFFFF;
		box-shadow: 8rpx 8rpx 32rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 24rpx;
		border: 2rpx solid #FFFFFF;

		.pItem {
			width: 100%;
			height: 96rpx;
			border-radius: 24rpx;

			.pi1 {
				image {
					width: 64rpx;
					height: 64rpx;
					margin-right: 16rpx;
				}
			}

			.pi2 {}
		}
	}

	.fixBox {
		width: 100%;
		height: 120rpx;
		padding: 0 32rpx;
		background: #FFFFFF;
		box-shadow: inset 0rpx 2rpx 0rpx 0rpx rgba(0, 0, 0, 0.05);
		position: fixed;
		bottom: 0;

		.jiesuan {
			width: 208rpx;
			height: 88rpx;
			background: #CB645E;
			line-height: 88rpx;
			text-align: center;
			color: #FFFFFF;
			font-size: 32rpx;
			font-weight: 500;
			border-radius: 16rpx;
			margin-left: 24rpx;
		}
	}

	.youhuijuan {
		width: 686rpx;
		height: 224rpx;
		background-color: #fff;
		border: 2rpx solid rgba(203, 100, 94, 0.24);
		border-radius: 24rpx;
		margin: 16rpx auto;
		border-left: none;

		.left {
			width: 258rpx;
			height: 100%;
			background-image: url('../../../static/images/juan.png');
		}

		.right {
			width: 364rpx;
			height: 100%;
			padding: 0 32rpx;
			background-color: #fff;
			border-radius: 30rpx;

			.rt {
				margin: 20rpx 0;

				text:nth-child(1) {
					display: inline-block;
					width: 152rpx;
					height: 40rpx;
					line-height: 40rpx;
					text-align: center;
					background: linear-gradient(270deg, #FFF1EE 0%, #FEEFF1 47%, #FEEAF6 100%);
					border-radius: 20rpx;
					font-size: 20rpx;
					font-weight: 600;
					color: #F22F19;
					margin-right: 16rpx;
				}

				text:nth-child(2) {
					font-size: 28rpx;
					font-weight: 400;
					color: rgba(0, 0, 0, 0.85);
				}
			}

			.rb {
				.rb1 {
					font-size: 20rpx;
					font-weight: 400;
					color: rgba(0, 0, 0, 0.45);
					line-height: 1.5;
				}

				.rb2 {
					width: 96rpx;
					height: 48rpx;
					line-height: 48rpx;
					background: #CB645E;
					border-radius: 8rpx;
					font-size: 24rpx;
					font-weight: 500;
					color: #FFFFFF;
					text-align: center;
				}
			}
		}
	}
</style>